using System.Web;
using System.Web.SessionState;
using System.Xml;
using System;

/*	-----------------------------------------------------------------------	
	Copyright:	umlungu consulting (pty) ltd
	Author:		Alan Benington	
	Started:	2006-04-02	
	Status:		release	
	Version:	1.0.3.20060329
	License:	GNU General Public License
	-----------------------------------------------------------------------	*/
	
namespace umlungu.engineX.blogX {
	/// <summary>
	/// Description of the x_profile class.
	/// <para>This is a 'lite' version of the xml profile object code (originally from the asp mechanism).</para>
	/// <para>The profile works as follows:</para>
	/// <para> - A profile is created in the session start up</para>
	/// <para> - The profile object contains an XmlDocument that holds all the profile data (form inputs etc) to be persisted for the session</para>
	/// <para> - The profile object contains either form field data ('fld' elements) used for form prepopulation or whole xml elements</para>
	/// <para> - other?...</para>
	/// <para>This 'lite' version differs from the original as follows:</para>
	/// <para> - The profile object itself is created in the session start (not just the XmlDocument)</para>
	/// <para> - Reduced methods and properties (expanded only as needed)</para>
	/// <para> - Structural differences in the way the data is stored in the profile xml</para>
	/// <para> - other?...</para>
	/// <para>The fields used in a profile should take note of the ECML (see comments at end).</para>
	///	<para>Google looks uses the last part of the field name for autofill</para>
	/// </summary>
	public class x_profile {
		#region Invisible properties
		private XmlDocument document;
		private string basefile = "profileX.xml";
		#endregion

		#region Visible properties
		/// <summary>The 'profile' document</summary>
		/// <value>An XmlDocument containing the profile</value>
		public XmlDocument ProfileXml {
			get { return document; }
		}
		/// <summary>The 'profile' element</summary>
		/// <value>An XmlElement containing the profile document element</value>
		public XmlElement Profile {
			get { return document.DocumentElement; }
		}
		/// <summary>The 'fields' element</summary>
		/// <value>An XmlElement containing the profile fields</value>
		public XmlElement Fields {
			get { return (XmlElement)Profile.SelectSingleNode("fields"); }
		}
		#endregion

		#region Constructors/Destructors
		/// <overloads>Constructor</overloads>
		/// <summary>Default constructor - typically not used</summary>
		public x_profile() : this("/") {
		}
		/// <summary>Used in the Session_OnStart event of a web application</summary>
		/// <param name="path">The path to the profile template file</param>
		public x_profile(string path) {
			initialise(path);
		}
		/// <summary>Used for a custom profile object </summary>
		/// <param name="path">The path to the profile template file</param>
		/// <param name="name">The name of the profile template file</param>
		public x_profile(string path, string name) {
			basefile = String.Concat(name, ".xml");
			initialise(path);
		}
		#endregion

		#region Public Profile methods
		#endregion

		#region Public Profile-Field methods
		/// <summary>Indicates if a field exists in the profile</summary>
		/// <param name="fldname">The name of the field in the profile</param>
		public bool Exists(string fldname) {
			return (getField(fldname) != null);
		}
		/// <summary>Gets a profile field element</summary>
		/// <param name="fldname">The name of the field in the profile</param>
		public XmlElement Field(string fldname) {
			return getField(fldname);
		}
		/// <summary>
		/// Gets a profile field value element
		/// </summary>
		/// <param name="fldname">The name of the field in the profile</param>
		public XmlElement Get(string fldname) {
			return getField(fldname, "value");
		}
		///	<overloads>Gets a profile field value</overloads>
		/// <summary>
		/// Gets value text, empty string if the field does not exist
		/// </summary>
		/// <param name="fldname">The name of the field in the profile</param>
		public string Value(string fldname) {
			XmlElement valel = getField(fldname, "value");
			return (valel != null)? valel.InnerText : "";
		}
		/// <summary>
		/// Gets value text, default value if the field does not exist
		/// </summary>
		/// <param name="fldname">The name of the field in the profile</param>
		/// <param name="defval">The default value of the field</param>
		public string Value(string fldname, string defval) {
			XmlElement valel = getField(fldname, "value");
			return (valel != null)? valel.InnerText : defval;
		}
		/// <summary>
		/// Gets a profile field subobj element
		/// </summary>
		/// <param name="fldname">The name of the field in the profile</param>
		public XmlElement GetSub(string fldname) {
			return getField(fldname, "subobjs");
		}
		/// <summary>
		/// Adds a profile field subobj element
		/// </summary>
		/// <param name="fldname">The name of the field in the profile</param>
		public XmlElement AddSub(string fldname) {
			XmlElement fld = Add(fldname);
			XmlElement fldsub = getField(fldname, "subobjs");
			if (fldsub == null) {
				fldsub = document.CreateElement("subobjs");
				fldsub = (XmlElement)fld.AppendChild(fldsub);
			}
			return fldsub;
		}
		///	<overloads>Adds value(s) to profile</overloads>
		/// <summary>Adds a profile field value</summary>
		/// <param name="fldname">The name of the field</param>
		public XmlElement Add(string fldname) {
			XmlElement fld = getField(fldname);
			if (fld == null) {
				fld = Fields.AppendChild(document.CreateElement("fld")) as XmlElement;
				fld.SetAttribute("name", fldname);
				fld.AppendChild(document.CreateElement("value")).InnerText = ""; ;
			}
			return fld;
		}
		/// <summary>Adds a profile field value</summary>
		/// <param name="fldname">The name of the field</param>
		/// <param name="fldvalue">The value of the field</param>
		public XmlElement Add(string fldname, string fldvalue) {
			XmlElement fld = getField(fldname);
			if (fld != null) {
				XmlElement fldval = getField(fldname, "value");
				if (fldval != null)
					fldval.InnerText = fldvalue;
				else
					fld.AppendChild(document.CreateElement("value")).InnerText = fldvalue;
			} else {
				fld = Fields.AppendChild(document.CreateElement("fld")) as XmlElement;
				fld.SetAttribute("name", fldname);
				fld.AppendChild(document.CreateElement("value")).InnerText = fldvalue;
			}
			return fld;
		}
		/// <summary>Adds a profile field value with a subobj value</summary>
		/// <param name="fldname">The name of the field</param>
		/// <param name="fldvalue">The value of the field</param>
		public XmlElement Add(string fldname, string subprompt, string subvalue) {
			XmlElement fld = Add(fldname);
			XmlElement fldsub = AddSub(fldname);

			if (fldsub != null) {
				XmlNode subobj = fldsub.SelectSingleNode(String.Concat("subwf_obj[value='", subvalue, "']"));
				if (subobj == null) {	// only add (not update)
					subobj = fldsub.AppendChild(document.CreateElement("subwf_obj"));
					subobj.AppendChild(document.CreateElement("value")).InnerText = subvalue;
					subobj.AppendChild(document.CreateElement("prompt")).InnerText = subprompt;
				}
			}
			return fld;
		}
		/// <summary>Adds form fields to profile</summary>
		/// <param name="request">The page Request object</param>
		public void Add(HttpRequest request) {
			String[] fldnames = request.Form.AllKeys;
			foreach (string fldname in fldnames)  {
				Add(fldname, request.Form[fldname]);
			}
		}
		/// <summary>Clears a profile field value and subobjs (if exist)</summary>
		/// <param name="fldname">The name of the field in the profile</param>
		public void Clear(string fldname) {
			XmlNode fld = getField(fldname);
			if (fld != null) {
				XmlNode subsnode = fld.SelectSingleNode("subobjs");
				if (subsnode != null)
					fld.RemoveChild(subsnode);
				XmlNode valnode = fld.SelectSingleNode("value");
				if (valnode != null)
					valnode.InnerText = "";
			}
		}
		/// <summary>Replaces node with fld or value in profile</summary>
		/// <param name="replace">The Element to be replaced</param>
		public void Replace(XmlElement replace) {
			string field = replace.GetAttribute("field");
			string value = replace.GetAttribute("value");
			string items = replace.GetAttribute("items");
			string select = replace.GetAttribute("select");
			string xml = replace.GetAttribute("xml");
			XmlElement repParent = replace.ParentNode as XmlElement;
			XmlDocument repDoc = replace.OwnerDocument;
			if (field != "") {
				//repParent.AppendChild(repDoc.ImportNode(getField(field), true));	// maybe only import children??
				replaceAll(getField(field), repParent, repDoc);
				repParent.RemoveChild(replace);
			} else if (value != "") {
				repParent.InnerText = Value(value);
			} else if (items != "") {
				replaceAll(getItems(items), repParent, repDoc);
				repParent.RemoveChild(replace);
			} else if (select != "") {
				replaceAll(Profile.SelectSingleNode(select), repParent, repDoc);
				repParent.RemoveChild(replace);
			} else if (xml != "") {
				replaceAll(getNode(xml), repParent, repDoc);
				repParent.RemoveChild(replace);
			} 
		}
		private void replaceAll(XmlNode srcNode, XmlNode destNode, XmlDocument destDoc) {
			if (srcNode != null) {
				foreach (XmlNode srcChild in srcNode.ChildNodes) {
					destNode.AppendChild(destDoc.ImportNode(srcChild, true));
				}
			}
		}
		#endregion

		#region Public Profile-Item methods
		///<remarks>
		/// This set of functionality is incomplete and needs to be expanded similar to the "Field" methods.
		/// Possibly refactor so that it utilises some kind of base class / generic methods
		///</remarks>

		/// <overloads>Clears a profile item list</overloads>
		/// <summary>Item list identified by name</summary>
		/// <param name="name">The name of the item list in the profile</param>
		public void ClearItems(string name) {
			ClearItems(getItems(name));
		}
		/// <summary>Item list node supplied</summary>
		public void ClearItems(XmlNode items) {
			if (items != null) {
				foreach (XmlNode item in items.SelectNodes("item")) {
					items.RemoveChild(item);
				}
			}
		}

		/// <summary>Gets a profile item element</summary>
		/// <param name="name">The name of the item list in the profile</param>
		public XmlElement Items(string name) {
			return getItems(name);
		}

		/// <summary>Gets a profile item element</summary>
		/// <param name="listname">The name of the item list</param>
		/// <param name="itemID">The ID of the item in the list</param>
		public XmlElement Item(string listname, string itemID) {
			return getItem(listname, itemID);
		}

		///	<overloads>Adds a new item list</overloads>
		/// <summary>Adds a blank item list or returns the cleared existing item list</summary>
		/// <param name="listname">The name of the item list</param>
		public XmlElement AddItems(string listname) {
			return AddItems(listname, true);
		}
		/// <summary>Adds a blank item list or returns the (cleared) existing item list</summary>
		/// <param name="listname">The name of the item list</param>
		/// <param name="clear">Flag to clear the item list</param>
		public XmlElement AddItems(string listname, bool clear) {
			XmlElement items = getItems(listname);
			if (items == null) {
				items = Profile.AppendChild(document.CreateElement("items")) as XmlElement;
				items.SetAttribute("name", listname);
			} else if (clear) {
				ClearItems(listname);
			}
			return items;
		}
		/// <summary>Adds a blank item list or returns the (cleared) existing item list</summary>
		/// <param name="listname">The name of the item list</param>
		/// <param name="source">Flag to clear the item list</param>
		/// <param name="clear">Flag to clear the item list</param>
		public XmlElement AddItems(string listname, XmlNodeList source, bool clear) {
			XmlElement items = AddItems(listname, clear);
			items.SetAttribute("count", source.Count.ToString());
			//int i = 0;
			foreach (XmlNode src in source) {
				AddItem(items, src);
				//i++;
				//AddItem(items, i.ToString(), src.InnerText);
			}
			return items;
		}

		///	<overloads>Adds item(s) to an item list</overloads>
		/// <summary>Adds a blank item</summary>
		/// <param name="listname">The name of the item list</param>
		public XmlElement AddItem(string listname) {
			return AddItem(listname, "");
		}
		/// <summary>Adds a item with an identifier</summary>
		/// <param name="listname">The name of the item list</param>
		/// <param name="itemID">The ID of the item to be added to the list</param>
		public XmlElement AddItem(string listname, string itemID) {
			return AddItem(listname, itemID,  "");
		}
		/// <summary>Adds a item with an identifier</summary>
		/// <param name="listname">The name of the item list</param>
		/// <param name="itemID">The ID of the item to be added to the list</param>
		public XmlElement AddItem(string listname, string itemID, string itemText) {
			return AddItem(AddItems(listname), itemID, itemText);
		}
		/// <summary>Adds a item with an identifier</summary>
		/// <param name="items">The item list element</param>
		/// <param name="itemID">The ID of the item to be added to the list</param>
		/// <param name="itemText">The text of the item to be added to the list</param>
		public XmlElement AddItem(XmlElement items, string itemID, string itemText) {
			XmlElement item = null;
			if (items != null) {
				item = items.AppendChild(document.CreateElement("item")) as XmlElement;
				if (itemID != "")
					item.SetAttribute("id", itemID);
				item.InnerText = itemText;
			}
			return item;
		}
		public XmlElement AddItem(XmlElement items, XmlNode itemSource) {
			XmlElement item;
			if (itemSource.HasChildNodes) {
				string txt = (itemSource.FirstChild.NodeType == XmlNodeType.Text) ? itemSource.FirstChild.Value : "";
				item = AddItem(items, "", txt);
				AddProperties(item, itemSource.ChildNodes);
			} else {
				item = AddItem(items, "", itemSource.InnerText);
			}
			if (item != null)
				AddProperties(item, itemSource as XmlElement);
			return item;
		}
		/// <summary>Adds an item and attribute properties</summary>
		/// <param name="listname">The name of the item list</param>
		/// <param name="properties">The node list of properties to be added to the item</param>
		public XmlElement AddItem(string listname, XmlNodeList properties) {
			return AddItem(listname, properties, "");
		}
		/// <summary>Adds an item and attribute properties</summary>
		/// <param name="listname">The name of the item list</param>
		/// <param name="properties">The node list of properties to be added to the item</param>
		public XmlElement AddItem(string listname, XmlNodeList properties, string itemID) {
			XmlElement item = AddItem(listname, itemID, "");
			AddProperties(item, properties);
			return item;
		}

		/// <summary>Adds an item and attribute properties</summary>
		/// <param name="listname">The name of the item list</param>
		/// <param name="properties">The node list of properties to be added to the item</param>
		public void AddProperties(XmlElement item, XmlElement src) {
			foreach (XmlAttribute property in src.Attributes)
				item.SetAttribute(property.Name, property.Value);
		}
		/// <summary>Adds an item and attribute properties</summary>
		/// <param name="listname">The name of the item list</param>
		/// <param name="properties">The node list of properties to be added to the item</param>
		public void AddProperties(XmlElement item, XmlNodeList properties) {
			foreach (XmlNode property in properties) {
				switch (property.NodeType) {
					case XmlNodeType.Attribute:
						item.SetAttribute(property.Name, property.Value);
						break;
					case XmlNodeType.Element:
						if (property.HasChildNodes) {
							if (property.FirstChild.NodeType == XmlNodeType.Text) {
								item.SetAttribute(property.Name, property.FirstChild.Value);
							}
							AddProperties(item, property.ChildNodes);	// ie call recursively
						} else {
							item.SetAttribute(property.Name, property.InnerText);
						}
						break;
				}
			}
		}
		#endregion

		#region Public Profile-Node methods
		///<remarks>
		/// This set of functionality is incomplete and needs to be expanded similar to the "Field" methods.
		/// Possibly refactor so that it utilises some kind of base class / generic methods
		///</remarks>

		/// <overloads>Clears a profile node</overloads>
		/// <summary>Node identified by name</summary>
		/// <param name="name">The name of the node in the profile</param>
		public void ClearNode(string name) {
			ClearNode(getNode(name));
		}
		public void ClearNode(XmlElement node) {
			node.RemoveAll();
		}

		/// <summary>Gets a profile node</summary>
		/// <param name="name">The name of the node in the profile</param>
		public XmlElement Node(string name) {
			return getNode(name);
		}

		///	<overloads>Adds a new item list</overloads>
		/// <summary>Adds a blank node or returns the cleared existing node</summary>
		/// <param name="name">The name of the node</param>
		public XmlElement AddNode(string name) {
			return AddNode(name, true);
		}
		/// <summary>Adds a blank item list or returns the (cleared) existing item list</summary>
		/// <param name="name">The name of the node</param>
		/// <param name="clear">Flag to clear the item list</param>
		public XmlElement AddNode(string name, bool clear) {
			XmlElement node = getNode(name);
			if (node == null) {
				node = Profile.AppendChild(document.CreateElement(name)) as XmlElement;
			} else if (clear) {
				ClearNode(name);
			}
			return node;
		}
		/// <summary>Adds a node to an existing (parent) node</summary>
		/// <param name="parent">The parent node</param>
		/// <param name="name">The name of the node</param>
		/// <param name="value">The text value of the node</param>
		public XmlElement AddNode(XmlNode parent, string name, string value) {
			XmlElement newnode = parent.AppendChild(document.CreateElement(name)) as XmlElement;
			newnode.InnerText = value;
			return newnode;
		}
		/// <summary>Adds a node to an existing (parent) node with an attibute</summary>
		/// <param name="parent">The parent node</param>
		/// <param name="name">The name of the node</param>
		/// <param name="value">The text value of the node</param>
		/// <param name="attname">The name of the attribute</param>
		/// <param name="attvalue">The value of the attribute</param>
		public XmlElement AddNode(XmlNode parent, string name, string value, string attname, string attvalue) {
			XmlElement newnode = AddNode(parent, name, value);
			newnode.SetAttribute(attname, attvalue);
			return newnode;
		}
		#endregion

		#region Protected methods
		#endregion

		#region Private methods
		/// <summary>
		/// Initialise on creation within the Session_OnStart
		/// </summary>
		/// <param name="path">The path to the profile template file</param>
		private void initialise(string path) {
			document = new XmlDocument();
			document.Load(String.Concat(path, basefile));
		}
		/// <overloads>Gets a profile field</overloads>
		/// <summary>Gets a profile field element</summary>
		/// <param name="fldname">The name of the field in the profile</param>
		private XmlElement getField(string fldname) {
			return Profile.SelectSingleNode(String.Concat("fields/fld[@name = '", fldname, "']")) as XmlElement;
		}
		/// <summary>Gets a profile field element child</summary>
		/// <param name="fldname">The name of the field in the profile</param>
		/// <param name="childname">The name of the child element of the field</param>
		private XmlElement getField(string fldname, string childname) {
			return Profile.SelectSingleNode(String.Concat("fields/fld[@name = '", fldname, "']/", childname)) as XmlElement;
		}

		/// <overloads>Gets a profile item list element.</overloads>
		/// <summary>Gets a profile item list element by name</summary>
		/// <param name="name">The name of the item list</param>
		private XmlElement getItems(string name) {
			return Profile.SelectSingleNode(String.Concat("items[@name = '", name, "']")) as XmlElement;
		}

		/// <summary>Gets a profile item element by name</summary>
		/// <param name="listname">The name of the item list</param>
		/// <param name="itemID">The ID of the item in the list</param>
		private XmlElement getItem(string listname, string itemID) {
			return Profile.SelectSingleNode(String.Concat("items[@name = '", listname, "']/items[@id = '", itemID, "']")) as XmlElement;
		}

		/// <summary>Gets a profile node element by name</summary>
		/// <param name="name">The name of the node</param>
		private XmlElement getNode(string name) {
			return Profile.SelectSingleNode(name) as XmlElement;
		}

		#endregion
	}
}

/*	-----------------------------------------------------------------------	
	ECML v1.1: Field Specifications for E-Commerce
	See http://www.ietf.org/rfc/rfc3106.txt
	-----------------------------------------------------------------------
	Field					  Name								 Min  Note
	-----					  ----								 ---  ---- 
	ship to title             Ecom_ShipTo_Postal_Name_Prefix       4  ( 1)
	ship to first name        Ecom_ShipTo_Postal_Name_First       15
	ship to middle name       Ecom_ShipTo_Postal_Name_Middle      15  ( 2)
	ship to last name         Ecom_ShipTo_Postal_Name_Last        15
	ship to name suffix       Ecom_ShipTo_Postal_Name_Suffix       4  ( 3)
	ship to company name      Ecom_ShipTo_Postal_Company          20
	ship to street line1      Ecom_ShipTo_Postal_Street_Line1     20  ( 4)
	ship to street line2      Ecom_ShipTo_Postal_Street_Line2     20  ( 4)
	ship to street line3      Ecom_ShipTo_Postal_Street_Line3     20  ( 4)
	ship to city              Ecom_ShipTo_Postal_City             22
	ship to state/province    Ecom_ShipTo_Postal_StateProv         2  ( 5)
	ship to zip/postal code   Ecom_ShipTo_Postal_PostalCode       14  ( 6)
	ship to country           Ecom_ShipTo_Postal_CountryCode       2  ( 7)
	ship to phone             Ecom_ShipTo_Telecom_Phone_Number    10  ( 8)
	ship to email             Ecom_ShipTo_Online_Email            40  ( 9)
	bill to title             Ecom_BillTo_Postal_Name_Prefix       4  ( 1)
	bill to first name        Ecom_BillTo_Postal_Name_First       15
	bill to middle name       Ecom_BillTo_Postal_Name_Middle      15  ( 2)
	bill to last name         Ecom_BillTo_Postal_Name_Last        15
	bill to name suffix       Ecom_BillTo_Postal_Name_Suffix       4  ( 3)
	bill to company name      Ecom_BillTo_Postal_Company          20
	bill to street line1      Ecom_BillTo_Postal_Street_Line1     20  ( 4)
	bill to street line2      Ecom_BillTo_Postal_Street_Line2     20  ( 4)
	bill to street line3      Ecom_BillTo_Postal_Street_Line3     20  ( 4)
	bill to city              Ecom_BillTo_Postal_City             22
	bill to state/province    Ecom_BillTo_Postal_StateProv         2  ( 5)
	bill to zip/postal code   Ecom_BillTo_Postal_PostalCode       14  ( 6)
	bill to country           Ecom_BillTo_Postal_CountryCode       2  ( 7)
	bill to phone             Ecom_BillTo_Telecom_Phone_Number    10  ( 8)
	bill to email             Ecom_BillTo_Online_Email            40  ( 9)
	receipt to                                                        (32)
	receipt to title          Ecom_ReceiptTo_Postal_Name_Prefix    4  ( 1)
	receipt to first name     Ecom_ReceiptTo_Postal_Name_First    15
	receipt to middle name    Ecom_ReceiptTo_Postal_Name_Middle   15  ( 2)
	receipt to last name      Ecom_ReceiptTo_Postal_Name_Last     15
	receipt to name suffix    Ecom_ReceiptTo_Postal_Name_Suffix    4  ( 3)
	receipt to company name   Ecom_ReceiptTo_Postal_Company       20
	receipt to street line1   Ecom_ReceiptTo_Postal_Street_Line1  20  ( 4)
	receipt to street line2   Ecom_ReceiptTo_Postal_Street_Line2  20  ( 4)
	receipt to street line3   Ecom_ReceiptTo_Postal_Street_Line3  20  ( 4)
	receipt to city           Ecom_ReceiptTo_Postal_City          22
	receipt to state/province Ecom_ReceiptTo_Postal_StateProv      2  ( 5)
	receipt to postal code    Ecom_ReceiptTo_Postal_PostalCode    14  ( 6)
	receipt to country        Ecom_ReceiptTo_Postal_CountryCode    2  ( 7)
	receipt to phone          Ecom_ReceiptTo_Telecom_Phone_Number 10  ( 8)
	receipt to email          Ecom_ReceiptTo_Online_Email         40  ( 9)
	name on card              Ecom_Payment_Card_Name              30  (10)
	card type                 Ecom_Payment_Card_Type               4  (11)
	card number               Ecom_Payment_Card_Number            19  (12)
	card verification value   Ecom_Payment_Card_Verification       4  (13)
	card expire date day      Ecom_Payment_Card_ExpDate_Day        2  (14)
	card expire date month    Ecom_Payment_Card_ExpDate_Month      2  (15)
	card expire date year     Ecom_Payment_Card_ExpDate_Year       4  (16)
	card protocols            Ecom_Payment_Card_Protocol          20  (17)
	consumer order ID         Ecom_ConsumerOrderID                20  (18)
	user ID                   Ecom_User_ID                        40  (19)
	user password             Ecom_User_Password                  20  (19)
	schema version            Ecom_SchemaVersion                  30  (20)
	wallet id                 Ecom_WalletID                       40  (21)
	end transaction flag      Ecom_TransactionComplete             -  (22)
	merchant home domain      Ecom_Merchant                      128  (23)
	processor home domain     Ecom_Processor                     128  (24)
	transaction identifier    Ecom_Transaction_ID                128  (25)
	transaction URL inquiry   Ecom_Transaction_Inquiry           500  (26)
	transaction amount        Ecom_Transaction_Amount            128  (27)
	transaction currency      Ecom_Transaction_CurrencyCode        3  (28)
	transaction date          Ecom_Transaction_Date               80  (29)
	transaction type          Ecom_Transaction_Type               40  (30)
	transaction signature     Ecom_Transaction_Signature         160  (31)
	end transaction flag      Ecom_TransactionComplete             -  (22)
	-----------------------------------------------------------------------	*/
